package com.example.demo.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * @Author: liull
 * @Description:对字符中的 各个英文字符（大小写分开统计），数字，空格进行统计，并按照统计个数由多到少输出,
 * 如果统计的个数相同，则按照ASII码由小到大排序输出 。如果有其他字符，则对这些字符不用进行统计。
 * @Date: Created in 16:57 2020/3/24
 * @Modified By:
 */
public class Main25 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        char[] chars = line.toCharArray();
        Map<Character, Integer> map = new TreeMap<>(Character::compareTo);
        for (char c : chars) {
            if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == ' ') {
                if (map.keySet().contains(c)) {
                    map.put(c, map.get(c).intValue() + 1);
                } else {
                    map.put(c, 1);
                }
            } else {
                map.put(c, 1);
            }
        }
        //        List<Map.Entry<String, Integer>> infoIds = new ArrayList<Map.Entry<String, Integer>>(
        //                (Collection<? extends Map.Entry<String, Integer>>) map.entrySet());
        //        Collection<Integer> values = map.values();
        //        Collections.sort((List<Integer>) values);
        //        System.out.println(map);
        ArrayList<Map.Entry<Character, Integer>> list = new ArrayList<>(map.entrySet());
        Collections.sort(list, (o1, o2) -> o1.getValue().compareTo(o2.getValue()));
        // 假设没有个数相同的
        for (Map.Entry<Character, Integer> entry : list) {
            System.out.print(entry.getKey());
        }

    }
}
